#ifndef CAPITALMARKETCNEXFORM_H
#define CAPITALMARKETCNEXFORM_H

#include <QWidget>
#include <QVector>
#include <QColor>
namespace Ui {
class CapitalMarketCNEXForm;
}

const int kMaxTimestampCount = 4;

class QMouseEvent;
//class QLabel;
class QPainter;
class QVBoxLayout;
class CapitalMarketCNEXForm : public QWidget
{
    Q_OBJECT
public:
    enum eBarType {
        AllMarket = 0,
        BigBank,
        SmallBank,
        NotBank,
        MaxCount = 4
    };

    const QColor kBarColor[MaxCount] = {QColor{201, 126, 51, 216}, QColor{103, 167, 56, 216}, QColor{50, 76, 196, 216}, QColor{124, 84, 195, 216}};

public:
    explicit CapitalMarketCNEXForm(QWidget *parent = nullptr);
    ~CapitalMarketCNEXForm();

    void clearData();
    void setData(int TimestampIndex/*[0, kMaxTimestampCount)*/, char* BarHeights /*of size MaxCount*/);

private slots:
    void legendClicked(bool checked);

protected:
    void paintEvent(QPaintEvent *event) override;
    void mouseMoveEvent(QMouseEvent *event) override;
    void setMaxHeight(int h);

private:
    void drawGridAndBar(QPainter *);
private:
    Ui::CapitalMarketCNEXForm *ui;
    //QVector<QLabel*> LabelYs;
    int MaxHeight{50}; // must be times of 10
    char BarHeight[kMaxTimestampCount][MaxCount]{{0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}}; // 0~100, so data type is char
    int HoverLabelX{kMaxTimestampCount};
};

#endif // CAPITALMARKETCNEXFORM_H
